package main

import "fmt"

func printSlice(s []int)  {
	fmt.Printf("len=%d cap=%d \n\n",len(s),cap(s))
}
func main() {
	var s[]int

	for i:=0;i<100;i++{
		s=append(s,2*i+1)
		printSlice(s)
	}
	fmt.Println(s)


	s1:=[]int{2,4,6,8}
	printSlice(s1)

	s2:=make([]int,16)
	printSlice(s2)

	s3:=make([]int,10,32)
	printSlice(s3)

	fmt.Println(" 拷贝：")
	copy(s2,s1)
	printSlice(s2)
	fmt.Println(s2)

	fmt.Println("删除...")
	s2=append(s2[:3],s2[4:]...)
	fmt.Println(s2)

	fmt.Println("popping from front")
	front:=s2[0]
	s2=s2[1:]
	fmt.Println(s2,front)


	fmt.Println("popping from back")
	tail:=s2[len(s2)-1]
	s2=s2[:len(s2)-1]
	fmt.Println(s2,tail)
}
